@import "../themes/ionic.globals";

// Ionic Font Family
// --------------------------------------------------

html.ios {
  --ion-default-font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Roboto", sans-serif;
}
html.md {
  --ion-default-font: "Roboto", "Helvetica Neue", sans-serif;
}

html {
  --ion-font-family: var(--ion-default-font);
}

body {
  background: var(--ion-background-color);
}

body.backdrop-no-scroll {
  overflow: hidden;
}

// TODO: Block scrolling in ion-content, breaks inside ion-modal
// body.backdrop-no-scroll .ion-page > ion-content {
//   --overflow: hidden;
// }


// Ionic Colors
// --------------------------------------------------
// Generates the color classes and variables based on the
// colors map

@mixin generate-color($color-name) {
  $value: map-get($colors, $color-name);

  $base: map-get($value, base);
  $contrast: map-get($value, contrast);
  $shade: map-get($value, shade);
  $tint: map-get($value, tint);

  --ion-color-base: var(--ion-color-#{$color-name}, #{$base}) !important;
  --ion-color-base-rgb: var(--ion-color-#{$color-name}-rgb, #{color-to-rgb-list($base)}) !important;
  --ion-color-contrast: var(--ion-color-#{$color-name}-contrast, #{$contrast}) !important;
  --ion-color-contrast-rgb: var(--ion-color-#{$color-name}-contrast-rgb, #{color-to-rgb-list($contrast)}) !important;
  --ion-color-shade: var(--ion-color-#{$color-name}-shade, #{$shade}) !important;
  --ion-color-tint: var(--ion-color-#{$color-name}-tint, #{$tint}) !important;
}

@each $color-name, $value in $colors {
  .ion-color-#{$color-name} {
    @include generate-color($color-name);
  }
}


// Page Container Structure
// --------------------------------------------------

.ion-page {
  @include position(0, 0, 0, 0);

  display: flex;
  position: absolute;

  flex-direction: column;
  justify-content: space-between;

  contain: layout size style;
  overflow: hidden;
  z-index: $z-index-page-container;
}

ion-route,
ion-route-redirect,
ion-router,
ion-select-option,
ion-nav-controller,
ion-menu-controller,
ion-action-sheet-controller,
ion-alert-controller,
ion-loading-controller,
ion-modal-controller,
ion-picker-controller,
ion-popover-controller,
ion-toast-controller,
.ion-page-hidden,
[hidden] {
  /* stylelint-disable-next-line declaration-no-important */
  display: none !important;
}

.ion-page-invisible {
  opacity: 0;
}

// Ionic Safe Margins
// --------------------------------------------------

html.plt-ios.plt-hybrid, html.plt-ios.plt-pwa {
  --ion-statusbar-padding: 20px;
}

@supports (padding-top: 20px) {
  html {
    --ion-safe-area-top: var(--ion-statusbar-padding);
  }
}

// TODO: remove once Safari 11.2 is no longer supported
@supports (padding-top: constant(safe-area-inset-top)) {
  html {
    --ion-safe-area-top: constant(safe-area-inset-top);
    --ion-safe-area-bottom: constant(safe-area-inset-bottom);
    --ion-safe-area-left: constant(safe-area-inset-left);
    --ion-safe-area-right: constant(safe-area-inset-right);
  }
}

@supports (padding-top: env(safe-area-inset-top)) {
  html {
    --ion-safe-area-top: env(safe-area-inset-top);
    --ion-safe-area-bottom: env(safe-area-inset-bottom);
    --ion-safe-area-left: env(safe-area-inset-left);
    --ion-safe-area-right: env(safe-area-inset-right);
  }
}
